import java.io.*;
import java.util.*;
import java.util.regex.*;

public class NamesInBible {
	private String filename;
	private Pattern patt;
	public Set<String> names;
	
	public NamesInBible(String filename, Pattern patt) {
		this.filename = filename;
		this.patt = patt;
		this.names = new HashSet<String>();
	}
	
	public void processFile() {
		try {
			BufferedReader rdr = new BufferedReader(new FileReader(this.filename));
			String line;
			
			while ((line = rdr.readLine()) != null) {
				processLine(line);
			}
			
			rdr.close();
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}
	
	private void processLine(String line) {
		Matcher m = this.patt.matcher(line);
		
		while (m.find()) {
			for (int i = 1; i <= m.groupCount(); i++) {
				this.names.add(m.group(i));
			}
		}
	}
	
	public static void main(String[] args) {
		Pattern p = Pattern.compile("I am ([A-Z][a-z]+)");
		//Pattern p = Pattern.compile("I am (\\w+)");
		// I am (\w+)
		// "I am (\\w+)"
		NamesInBible n = new NamesInBible("bible.txt", p);
		
		n.processFile();
		
		for (String name : n.names) {
			System.out.println(name);
		}
	}
}
